
$(document).ready(function(){
	var windowHeight = $(document).height();
	console.log('windowHeight='+windowHeight);
	//设置默认高度
	$("#adminMain2").css("min-height",windowHeight-40);
	$("#leftMenuTree").css("min-height",windowHeight-40);
	
	$("#loginOut").click(function(){
		$.zui.store.clear();  
		location.href='../login2.jsp';
	});
	//动态获取左边菜单数据
	var queryLeftMenuUrl = adminQueryUrl + menuService;
	var token = $.zui.store.get("token");
	var userId = $.zui.store.get("userId");
	var param = "action=queryLeftMenuList";
	console.log('token='+token+",userId="+userId);
	$.ajax({
		url:queryLeftMenuUrl,
		type:'post',
		beforeSend:function(xhr){
			xhr.setRequestHeader("token",token);
			xhr.setRequestHeader("userId",userId);
		},
		header:{"token":token,"userId":userId},
		data:param,
		dataType:"JSON",
		success:function(result){
			console.log(result);
			if (result.success == '1'){
				// 获取 tree 实例
				var myTree = $('#leftMenuTree').data('zui.tree');
				var menuList = result.menuList;
				var resultHtml = "";
				for(var i=0;i<menuList.length;i++){
					resultHtml += '<li>';
					resultHtml += '<a href="#"  style="color:white;"><i class="icon icon-list"></i>'+menuList[i].title+'</a>';
					if (menuList[i].children.length>0){
						resultHtml += '<ul>';
						for(var j=0;j<menuList[i].children.length;j++){
							resultHtml += '<li><a href="javascript:;"  style="color:white;"  onclick="'+menuList[i].children[j].url
							+'" ><i class="icon icon-circle-blank"></i>'+menuList[i].children[j].title+'</a></li>'
						}
						resultHtml += '</ul>';
					}
					resultHtml += '</li>';
				}
				$("#leftMenuTree").html(resultHtml);
			}
			else {
				new $.zui.Messager('获取数据出错', {
				    type: 'warning', // 定义颜色主题
				    placement: 'center' // 定义显示位置
				}).show();
			}
		},
		error:function(result){
			new $.zui.Messager('系统繁忙,请稍候再试!', {
			    type: 'warning', // 定义颜色主题
			    placement: 'center' // 定义显示位置
			}).show();
		}
	});
});

//重新加载右边页面
function reloadMainRight(name){
	$("#adminMainRight2").empty();
	$("#adminMainRight2").load(name);
}